﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="TestClear.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Mathematics.LinearAlgebra.Sequential.Tests.CcsSparseMatrixTest
{
    #region Usings

    using System;

    using NUnit.Framework;

    #endregion

    /// <summary>
    ///     Test suite for <see cref="CcsSparseMatrixExtensions.Clear{T}"/>.
    /// </summary>
    [TestFixture]
    [Category("ExulLibrary.Mathematics.LinearAlgebra.Sequential.CcsSparseMatrixExtensions")]
    public sealed class TestClear
    {
        /// <summary>
        ///     Tests the method.
        /// </summary>
        [Test]
        public void TestMethod()
        {
            // Arrange
            var matrix = new CcsSparseMatrix<object>(
                rowsCount: 3,
                columnsCount: 2,
                columnsBegins: new[] { 0, 2, 4 },
                rowsIndexes: new[] { 0, 2, 0, 1 },
                data: new[] { new object(), new object(), new object(), new object() });

            // Act
            matrix.Clear();

            // Assert
            Assert.That(matrix.Values, Has.All.Null);
        }

#if SAFE

        /// <summary>
        ///     Tests the method when matrix is <see langword="null"/>.
        /// </summary>
        [Test]
        public void WhenMatrixIsNull()
        {
            // Act and Assert
            Assert.That(
                () => CcsSparseMatrixExtensions.Clear<object>(null),
                Throws.TypeOf<ArgumentNullException>().With.Property("ParamName").EqualTo("matrix"));
        }

#endif
    }
}